#pragma once

#ifndef _CLINKSHELL_H_
#define _CLINKSHELL_H_

#include "Utils/T2List.h"
#include "Utils/T2AvlList.h"

class CChar;

class CLinkshell
{
private:
	//object variables
	unsigned int m_LsId;
	char m_LsName[20];
	char m_LsNameComp[16];
	unsigned short m_LsColor;
	char m_LsMesPoster[17];
	char m_LsMes[115];
	unsigned int m_LsMesTime;
	//list of all online linkshell members
	T2List<unsigned int,CChar*>* m_onlineMembers;

	//class variables
	static T2List<unsigned int,CLinkshell*>* m_LoadedLinkshells;

	//class functions
	static void checkLoadedLinkshells(void);
	static void addLinkshellToList(CLinkshell* newLinkshell);

public:
	//constructors
	CLinkshell();
	CLinkshell(unsigned int lsId, char* lsName, unsigned short lsColor);
	CLinkshell(unsigned int lsId, char* lsName, unsigned short lsColor, char* lsMes, char* lsMesPoster, unsigned int lsMesTime); 

	//object functions
	unsigned int getLsId(void);
	char* getLsName(void);
	char* getLsNameComp(void);
	unsigned short getLsColor(void);
	char* getLsMes(void);
	char* getLsMesPoster(void);
	unsigned int getLsMesTime(void);

	void addOnlineMember(CChar* newMember);
	void removeOnlineMember(CChar* newMember);
	T2List<unsigned int,CChar*>* getOnlineMemberList(void);

	void setLsMes(char* lsMes, char* lsMesPoster);

	//class functions
	static CLinkshell* getLinkshellById(unsigned int linkshellId);
	static void breakLinkshell(unsigned int linkshellId);
	static void breakLinkshellItems(CChar* targetChar,unsigned int linkshellId);
	static void CLinkshell::modifyLinkshellItems(CChar* targetChar, unsigned char operation);
	static int createLinkshellPacket(CChar* schar, char* data);
	static unsigned short getLinkshellItem(CChar* schar,unsigned char itemSlot);
	static int addLinkPearl(CChar* schar, CLinkshell* linkshell);
	static int addLinkPearl(CChar* schar);
	static int changeLinkPearlIntoSack(CChar* schar, unsigned char itemSlot);
	static void uncompressLsName(char* inputComp, char* outputUncomp);
	static void compressLsName(char* inputUncomp, char* outputComp);
	static void sendLsMsg(CChar* receiver);
};

#endif